<?php require_once(dirname(__FILE__)."/../config/config.php"); 
include (dirname(__FILE__)."/../include/zy_function2.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理页面</title>
<style type="text/css">
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
a.current {text-decoration: underline;font-weight: bold;}
</style> 
</head>
<body>
<?php  
if($_SESSION['admin_name']=="")
{

	echo "<script>location.href='admin_login.php';</script>";
}
?>
<?php
$sql="select count(shop_id) num from zy_shop where is_delete=0".$where;
//当前页
$p=$_REQUEST['p'];
if(!$p>0){
	$p=1;
}
//每页记录条数
$pagesize=10;
$Page=page($p,$sql,'','',$pagesize);
mysql_query($sql);
$sql1="select * from zy_shop where 1=1 ".$where."order by update_time desc limit ".($p-1)*$pagesize.",".$pagesize;
$result=mysql_query($sql1);
$n=1;
?>
<form id="form1" name="form1" method="post" action="">
  <table width="900" height="25" align="center" border="1">
    <tr>
	  <th width="173" height="25">店铺名称</th>
      <th width="173" height="25">店铺地址</th>
	  <th width="173" height="25">外送费</th>
      <th width="211" height="25">店铺管理员账号</th>
      <th width="317" height="25">备注</th>
	 
    </tr>
 
  <?php
  while($shop=mysql_fetch_array($result)){
  ?>
  
    <tr>
	 
      <td width="173" height="25"><a href="admin_shop.php?id=<?php echo $shop['shop_id'];  ?>"><?php echo $shop['shop_name']; ?></a></td>
      <td width="173" height="25"><?php echo $shop['shop_address']; ?></td>
	  <td width="173" height="25"><?php echo $shop['surcharge']; ?></td>
      <td width="211" height="25"><?php 
		    $shop_id=$_REQUEST['shop_id'];
	  		$sql1=mysql_query("select * from zy_user where shop_id=".$shop['shop_id']);
			$rs=mysql_fetch_array($sql1);
			if($rs['shop_id']){?>
        <a href="shop_user_update.php?id=<?php echo $shop['shop_id'];  ?>"> <?php echo $rs['mail'];?> </a>
        <?php
			}else{
	  ?>
        <a href="shop_user_registration.php?id=<?php echo $shop['shop_id'];  ?>">注册</a>
        <?php 
			}
	  ?>      </td>
      <td width="143" height="25"><a href="shop_edit.php?id=<?php echo $shop['shop_id'];  ?>">修改店铺信息</a>&nbsp;&nbsp;
      <a href="admin_delete.php?id=<?php echo $shop['shop_id'];  ?>">删除店铺</a></td>
	  
    </tr>
	<?php }?>

  </table>
  </form><br />
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="border">
  <tr>
    <td height="30" align="center" bgcolor="#FFFFFF"> 
      <?php if($Page['currentPage']!=1){?>
      <a href="<?php echo SITE_ROOT?>/admin/admin_management.php?shop_id=<?php echo $shop_id;?>">首页</a> 
	  <a href="<?php echo SITE_ROOT?>/admin/admin_management.php?shop_id=<?php echo $shop_id;?>&p=<?php echo $Page['currentPage']-1;?>">上一页</a>
     <?php } ?>
      <?php  for ($i=$Page['begin'];$i<=$Page['end'];$i++){?>
      <a href="<?php echo SITE_ROOT?>/admin/admin_management.php?shop_id=<?php echo $shop_id;?>&p=<?php echo $i;?>" <?php echo $i==$Page['currentPage'] ? "class='current'":''?> ><?php echo $i;?></a>
      <?php } ?>
      <?php if($Page['currentPage']!= $Page['totalPages']){?>
      <a href="<?php echo SITE_ROOT?>/admin/admin_management.php?shop_id=<?php echo $shop_id;?>&p=<?php echo $Page['currentPage']+1;?>">下一页</a>
	   <a href="<?php echo SITE_ROOT?>/admin/admin_management.php?shop_id=<?php echo $shop_id;?>&p=<?php echo $Page['totalPages'];?>">尾页</a> 
	    <?php }?>
	   </td>    
  </tr>
</table>
</body>
</html>
